//
//  UIFont+Extend.swift
//  Tala
//
//  Created by 千策万划-mini on 2025/4/28.
//

import Foundation

extension UIFont {
    
    static func customBoldFont(name: String = "Baloo2-Bold", size: CGFloat, weight: UIFont.Weight = .regular) -> UIFont {
        self.customFont(name: name, size: size, weight: weight)
    }
    
    static func customExtraBoldFont(name: String = "Baloo2-ExtraBold", size: CGFloat, weight: UIFont.Weight = .regular) -> UIFont {
        self.customFont(name: name, size: size, weight: weight)
    }
    
    static func customMediumFont(name: String = "Baloo2-Medium", size: CGFloat, weight: UIFont.Weight = .regular) -> UIFont {
        self.customFont(name: name, size: size, weight: weight)
    }
    
    static func customRegularFont(name: String = "Baloo2-Regular", size: CGFloat, weight: UIFont.Weight = .regular) -> UIFont {
        self.customFont(name: name, size: size, weight: weight)
    }
    
    static func customSemiBoldFont(name: String = "Baloo2-SemiBold", size: CGFloat, weight: UIFont.Weight = .regular) -> UIFont {
        self.customFont(name: name, size: size, weight: weight)
    }
    
    static func customFont(name: String, size: CGFloat, weight: UIFont.Weight = .regular) -> UIFont {
        if let customFont = UIFont(name: name, size: size) {
            return customFont
        }
        // 找不到自定义字体则返回系统字体
        return UIFont.systemFont(ofSize: size, weight: weight)
    }
}
